const API_KEY = 'ac73d8fd18b94d95ba13b43e4aa12c6d';
const API_URL = 'https://api.football-data.org/v4/competitions';

// 获取指定联赛的队伍信息
export const getTeamsByCompetition = async (competitionId) => {
    try {
        const response = await fetch(`${API_URL}/${competitionId}/teams`, {
            headers: {
                'X-Auth-Token': API_KEY
            }
        });

        if (!response.ok) {
            throw new Error(`HTTP error! status: ${response.status}`);
        }

        const data = await response.json();
        return data.teams.map(team => ({
            id: team.id,
            name: team.name,
            crestUrl: team.crestUrl
        }));
    } catch (error) {
        console.error('Error fetching teams:', error);
        return [];
    }
};